﻿// Genius
// Copyright (C) 2016 Dirk Friedenberger, www.frittenburger.de
//   
// This source file is subject to the Microsoft Public License (Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Genius.Brain.Shared.BO;
using Genius.Locator.Internal;
using Genius.SlackBot.Shared.Converter;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Genius.SlackBot.Shared.Locator
{
    public class SlackBotLocator
    {
        public static ISlackBot GetSlackBot(string path)
        {
            var bot = ContainerHolder.Resolve<ISlackBot>();

            JObject config = JObject.Parse(File.ReadAllText(path + @"\config.json"));

            bot.Path = path;
            bot.Token = config["token"].Value<String>();
            bot.Api = config["slackapi"].Value<String>();

            return bot;
        }

        public static IConverter<JToken,IMessage> GetJsonToMessageConverter()
        {
            return ContainerHolder.Resolve<IConverter<JToken, IMessage>>();
        }

        public static IConverter<JToken, IChannel> GetJsonToChannelConverter()
        {
            return ContainerHolder.Resolve<IConverter<JToken, IChannel>>();
        }
        public static IConverter<JToken, IInstantMessaging> GetJsonToIMConverter()
        {
            return ContainerHolder.Resolve<IConverter<JToken, IInstantMessaging>>();
        }

    }
}
